package com.pk.platform.business.data.service.impl;

import java.util.List;

import com.pk.platform.business.data.dao.IBaseDataDao;
import com.pk.platform.business.data.service.IBaseDataService;
import com.pk.platform.business.data.vo.BaseDataVO;
import com.pk.platform.domain.data.BaseData;
import com.pk.platform.util.page.ListPage;
import com.pk.platform.util.page.Pager;

public class BaseDataServiceImpl implements IBaseDataService {

	private IBaseDataDao baseDataDao;
	
	public ListPage queryBaseData(BaseDataVO bvo, Pager pager) {
		return baseDataDao.queryBaseData(bvo, pager);
	}

	public List<BaseData> queryBaseDataByParentId(String parentId) {
		return baseDataDao.queryBaseDataByParentId(parentId);
	}
	
	public BaseData queryBaseDataById(String id)
	{
		return baseDataDao.get(BaseData.class, id);
	}
	
	public void delBaseDatas(String[] bdIds)
	{
		baseDataDao.delete(BaseData.class, bdIds);
	}
	
	public boolean addBaseData(BaseData bd)
	{
		BaseData baseData = baseDataDao.get(BaseData.class, bd.getId());
		if(baseData == null)
		{
			baseDataDao.add(bd);
			return true;
		}
		return false;
	}
	
	public void updateBaseData(BaseData baseData)
	{
		BaseData bd = baseDataDao.get(BaseData.class, baseData.getId());
		bd.setDataValue(baseData.getDataValue());
		bd.setSort(baseData.getSort());
	}
	
	

	public IBaseDataDao getBaseDataDao() {
		return baseDataDao;
	}

	public void setBaseDataDao(IBaseDataDao baseDataDao) {
		this.baseDataDao = baseDataDao;
	}

}
